package com.adcc.zkdemo.web;

import com.adcc.zkdemo.core.Airport;
import com.adcc.zkdemo.core.AirportService;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.select.annotation.VariableResolver;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zkplus.spring.DelegatingVariableResolver;

@VariableResolver(DelegatingVariableResolver.class)
public class MyViewModel {

	private int count;

	@WireVariable
	private AirportService airportService;
	
	@Init
	public void init() {
		count = 100;
		Airport saved = new Airport();
		saved.setCode3("ABC");
		saved.setCode4("ABCD");
		airportService.add(saved);
	}

	@Command
	@NotifyChange("count")
	public void cmd() {
		++count;
	}

	public int getCount() {
		return count;
	}
}
